﻿import cn.eminia.A2.ui.selBox;
import mx.utils.Delegate;
/**
 * ...
 * @author wangjun
 */
class cn.eminia.A2.ui.manager.selBoxManager 
{
	private var _count:Number;
	private var _arr:Array;
	public function selBoxManager() 
	{
		this._count = 0;
		this._arr = [];
		
	}
	public function add(oo:selBox) 
	{
		//trace(oo.constructor== selBox)
		//trace(oo.constructor== MovieClip)
		//if(oo.constructor != selBox){throw new Error("!!cn.eminia.A2.ui.manager.selBoxManager::add 所附加的不是selBox类实例")}
		oo.watch("sel", Delegate.create(this, onWatch)); 
		this._arr.push(oo);
	}
	public function init() {
		for (var i:Number = 0; i < this._arr.length; i++) 
		{
			var oo = this._arr[i];
			trace(oo._sel)
			if (oo._sel) {
				this._count++;
			} 
		}
		trace('_count = '+this._count)
	}
	public function onWatch(vv, ovv, nvv) {
		if (nvv==1) {
			this._count ++;
		}else if (nvv==0){
			this._count --;			
		}
	}
	public function get count():Number{
		return this._count
		
	}
	
}